package com.kee.server.dao;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.kee.share.bean.Exam;

public class ExamDao extends BaseDao implements IExamDao {

	
	public int add(Exam exam) throws SQLException {
		Object a = sqlMapClientMaster.insert("addExam", exam);
		return (Integer) a;
	}

	
	public void update(Exam exam) throws SQLException {
		sqlMapClientMaster.update("updateExam", exam);
	}
	
	
	public Exam query(int id) throws SQLException {
		Exam exam = (Exam)sqlMapClientMaster.queryForObject("QueryExamById", id);
		return exam;
	}

	public List<Exam> query(int pageNo, int pageSize) throws SQLException {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("index", (pageNo - 1) * pageSize);
		map.put("size", pageSize);
		List<Exam> exams = sqlMapClientMaster.queryForList("queryByList", map);
		return exams;
	}
	
	
	public static void main(String[] args) {
		ExamDao ed = new ExamDao();
		try {
			List<Exam> exams = ed.query(1, 10);
			System.out.println(exams);
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}


	
}
